<template>
  <div class="homework-detail-container">
    <div class="homework-detail-title">
      {{item.topic}}
    </div>
    <el-input maxlength="1024" :disabled="!idEditing" style="font-size: 24px; margin-top: 20px" :autosize="{ minRows: 8, maxRows: 8}" v-model="item.content" type="textarea" />
    <el-row style="margin-top: 20px">
      <el-col :span="4" v-if="role == 'teacher'">
        <el-button v-if="!idEditing" type="danger" size="small" @click="()=>{this.idEditing = true}">
          修改描述
        </el-button>
        <el-button v-else type="danger" size="small" @click="saveDesc">
          确认修改
        </el-button>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  import {
    deleteOneHomeworkAttachfile,
    getHomeworkAttachFileListByHid,
    getOneHomework, getOneNotice, updateOneHomework, updateOneNotice,
    uploadHomeworkAttachFile, uploadHomeworkSubmitFile,
  } from "../../api";
  import {HOST, ROLE_KEY, UID_KEY} from "../../constants";

export default {
  name: 'HomeworkDetail',
  data() {
    return {
      role: localStorage.getItem(ROLE_KEY),
      idEditing: false,
      host: HOST,
      item: {

      },
    }
  },
  methods: {
    saveDesc() {
      this.idEditing = false
      updateOneNotice({
        id: this.$route.params.id,
        desc: this.item.content
      }).then(res => {
        this.$message.success("修改成功")
      })
    },
  },
  mounted() {
    getOneNotice({id: this.$route.params.id}).then(res => {
      this.item = res.data
    })
  }
}
</script>

<style lang="scss" scoped>
.homework-detail {
  &-container {
    margin: 30px;
  }
  &-title {
    font-size: 30px;
    line-height: 46px;
  }
  &-subtitle {
    font-size: 24px;
    margin-top: 25px;
  }
  &-attachfile-list {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
  }
  &-attachfile-item {
    display: flex;
    margin-bottom: 10px;
    margin-right: 15px;
  }
}
.edit-btn {
}
</style>
